<template>
  <div id="invSernumInventoryDifference_readycheck" style="height:100%" v-loading="loading">
    <v-tableTitle :btnConfig="btnConfig" @check="check" @selfChecking="selfChecking"> </v-tableTitle>
    <GTable
      class="base-grid"
      :hasCheck="true"
      v-model="gridObj"
      :highlightCurrentRow="false"
      :disabled="true"
      api="invSernumInventoryDifference/selectInvSernumInventoryDifferenceList/13701"
      :rules="rules"
      :otherHeight="72"
      :tmsShowFilter="true"
      :columnConfig="columnConfig"
      :apiParams="{ serialDiffStatus: 13701 }"
      :extraColumns="extraColumns"
      :showSummary="false"
      :pagination="true"
      @selection-change="handleSelectionChange"
      @filter-changed="filterChanged"
      @cell-dblclick="cellDblclick"
      @grid-ready="agGridReady"
    >
    </GTable>

    <el-drawer
      :title="$t('ex.invSernumInventoryCheck')"
      :visible.sync="dialogFlag"
      direction="rtl"
      size="60%"
      destroy-on-close
    >
      <router-view></router-view>
    </el-drawer>
  </div>
</template>

<script>
import baseMixin from "@/mixins/BaseMixin";
import agGridBaseMixin from "@/mixins/AgGridBaseMixin";

export default {
  name: "invSernumInventoryDifference_readycheck",
  mixins: [baseMixin, agGridBaseMixin],
  props: {
    inputData: {
      type: Object,
    },
  },
  data() {
    return {
      height: 0,
      columnConfig: {
        menu_code: "invSernumInventoryDifference",
        menu_list_code: "invSNInventoryDifferenceReady",
      },
      dialogFlag: false,
      selectData: [],
    };
  },
  computed: {
    btnConfig() {
      return [{ label: this.$t('ex.check'), certigier: false||!this.btnPermNameList.includes('WM06021201'), invalid: "check" },
        { label: this.$t('ex.selfChecking'), certigier: false||!this.btnPermNameList.includes('WM06021202'), invalid: "selfChecking" }];
    },
  },
  watch: {
    $route(data) {
      if (data.name === "invSNInventoryDifferenceDeawer") {
        this.dialogFlag = true;
      }else{
        this.dialogFlag = false;
      }
    },
  },
  methods: {
    handleSelectionChange(data) {
      this.selectData = data;
    },
    //设置弹框
    check() {
      let arr = this.selectData;
      if (arr.length === 0) {
        this.$message.error(this.$t('msg.msg16'));
        return;
      }
      if (arr.length !== 1) {
        this.$message.error(this.$t('msg.msg32'));
        return;
      }
      let data = arr[0];
      this.$store.commit("setRouteData", data);
      this.dialogFlag = true;
      this.$nextTick(() => {
        this.$router.push({ name: "invSNInventoryDifferenceDeawer" });
      });
    },
    async selfChecking(){
      try{
        let res = await this.$api.post(`/invSernumInventoryDifference/selfChecking`, {});
        
          this.$message.success(res.returnMgr);
        
      } catch (e) {
        this.$message.error(e);
      }
    },
  },
  mounted() {
    this.$store.commit("setSkip", {});
    this.$store.commit("setRouteId", "");
    this.$store.commit("setNewFlag", false);
    this.$store.commit("setRouteData", {});
    // this.getTableData(1, {});
  },
};
</script>

<style scoped>
#invSernumInventoryDifference_readycheck {
  width: 100%;
  height: 99%;
}
</style>
